package com.qing.thread.priority;

/**
 * 线程优先级范围 1-10
 */
public class PriorityThread implements Runnable {

    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName() + "优先级为：——————》" + Thread.currentThread().getPriority());
    }


    public static void main(String[] args) {
        System.out.println("Main主线程默认优先级：" + Thread.currentThread().getPriority());

        PriorityThread priorityThread = new PriorityThread();

        Thread thread1 = new Thread(priorityThread, "one");
        Thread thread2 = new Thread(priorityThread, "two");
        Thread thread3 = new Thread(priorityThread, "three");
        Thread thread4 = new Thread(priorityThread, "four");
        Thread thread5 = new Thread(priorityThread, "five");
        Thread thread6 = new Thread(priorityThread, "six");

        thread1.setPriority(10);
        thread1.start();

        thread2.setPriority(Thread.MIN_PRIORITY);
        thread2.start();

        thread3.setPriority(10);
        thread3.start();

        thread4.setPriority(6);
        thread4.start();

        thread5.setPriority(2);
        thread5.start();

        thread6.setPriority(3);
        thread6.start();
    }
}
